<!DOCTYPE html>
<html>

<head>
  
  <title>windows 11 安装 minikube | 布.</title>
  <meta name="google-site-verification" content="" />
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta itemprop="name" content="布." />
  <meta itemprop="description" content="漫长岁月" />
  <meta itemprop="image" content="" />
  <link rel="shortcut icon" href="" type="image/x-icon">
  <!-- keywords and description -->
  
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  
  
<link rel="stylesheet" href="/css/style.css">

  <script src="//cdn.jsdelivr.net/npm/@waline/client/dist/Waline.min.js"></script>
<meta name="generator" content="Hexo 6.0.0"></head>

<body>
  <div id="container">
    <header>
  <div class="site-title">
    <a href="/">
      布.
    </a>
  </div>
  
  <div class="site-subtitle">
    漫长岁月
  </div>
  
  
  <p class="links">
    
    <a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_29485177">
      <img src="/images/links/link.png" alt="CSDN">
    </a>
    
  </p>
  
</header>
    <div id="main">
      <article class="post">
  <h3 class="date">
  <time datetime="2022-05-13T09:58:24.000Z">
    May 13, 2022
  </time>
</h3>
  <h1>windows 11 安装 minikube</h1>
  <p class="post-info">
  
  
</p>
  
  
  <article>
    <h2 id="windows-11-安装-minikube"><a href="#windows-11-安装-minikube" class="headerlink" title="windows 11 安装 minikube"></a>windows 11 安装 minikube</h2><p>1.安装 [docker](<a target="_blank" rel="noopener" href="https://www.docker.com/">Home - Docker</a>)</p>
<p>2.访问官网 [minikube](<a target="_blank" rel="noopener" href="https://minikube.sigs.k8s.io/docs/start/">minikube start | minikube (k8s.io)</a>)</p>
<h4 id="下载安装包"><a href="#下载安装包" class="headerlink" title="下载安装包"></a>下载安装包</h4><p>选择windows安装包<br><img src="https://img-blog.csdnimg.cn/f7658477882d43f0be13f4df33f74f78.png" alt="在这里插入图片描述"></p>
<h4 id="设置环境变量"><a href="#设置环境变量" class="headerlink" title="设置环境变量"></a>设置环境变量</h4><p>以管理员运行 PowerShell ，运行以下命令</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$oldPath = [Environment]::GetEnvironmentVariable(&#x27;Path&#x27;, [EnvironmentVariableTarget]::Machine)</span><br><span class="line">if ($oldPath.Split(&#x27;;&#x27;) -inotcontains &#x27;C:\minikube&#x27;)&#123; `</span><br><span class="line">  [Environment]::SetEnvironmentVariable(&#x27;Path&#x27;, $(&#x27;&#123;0&#125;;C:\minikube&#x27; -f $oldPath), [EnvironmentVariableTarget]::Machine) `</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>或者手动设置<br>系统设置 - 环境变量 - 添加系统变量</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Path 添加 C:\minikube</span><br></pre></td></tr></table></figure>

<h4 id="启动-minikube"><a href="#启动-minikube" class="headerlink" title="启动 minikube"></a>启动 minikube</h4><p>因为网络问题，可能下载image时会产生问题，需要添加一些参数，官方有说明</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">--image-mirror-country</span><br><span class="line">Country code of the image mirror to be used. Leave empty to use the global one. For Chinese mainland users, set it to cn.</span><br><span class="line"></span><br><span class="line">--image-repository</span><br><span class="line">Alternative image repository to pull docker images from. This can be used when you have limited access to gcr.io. Set it to &quot;auto&quot; to let minikube decide one for you. For Chinese mainland users, you may use local gcr.io mirrors such as registry.cn-hangzhou.aliyuncs.com/google_containers.</span><br><span class="line"></span><br><span class="line">--driver</span><br><span class="line">Used to specify the driver to run Kubernetes in. The list of available drivers depends on operating system.</span><br></pre></td></tr></table></figure>
<p>所以需要运行</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">minikube start --driver=docker --image-mirror-country=cn --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers</span><br></pre></td></tr></table></figure>
<p>查看状态</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">minikube status</span><br></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/eb3034854542499eab19edecb4939e72.png" alt="在这里插入图片描述"></p>
<h4 id="部署应用"><a href="#部署应用" class="headerlink" title="部署应用"></a>部署应用</h4><p>官方命令</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4</span><br></pre></td></tr></table></figure>
<p>这个 k8s.gcr.io&#x2F;echoserver:1.4 image 因为网络问题无法下载，在docker中查找该image的镜像<br><img src="https://img-blog.csdnimg.cn/d64b80a635d64a2ea323a0c1b9c0a9be.png" alt="在这里插入图片描述"><br>这里就采用第一个，需要注意的是官方的镜像监听的是8080端口，该镜像是80端口</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 创建一个名叫 hello-minikube 的部署</span><br><span class="line">kubectl create deployment hello-minikube --image=cilium/echoserver</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">// 将集群的80端口暴露，作为一个 service</span><br><span class="line">kubectl expose deployment hello-minikube --type=NodePort --port=80</span><br><span class="line"></span><br><span class="line">// 将宿主机器的7080端口转发到集群的80端口</span><br><span class="line">kubectl port-forward service/hello-minikube 7080:80</span><br></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/1218ada6b1ee4e62a373f3c02afad11f.png" alt="在这里插入图片描述"><br>访问 <a target="_blank" rel="noopener" href="http://localhost:7080/">http://localhost:7080</a></p>
<h4 id="相关命令"><a href="#相关命令" class="headerlink" title="相关命令"></a>相关命令</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">kubectl get pod -o wide		// 获取当前所有 pod 信息</span><br><span class="line">kubectl get deployment		// 获取当前所有 deployment 信息</span><br><span class="line">kubectl get service			// 获取当前所有 service 信息</span><br><span class="line">kubectl get all				// 获取当前所有信息</span><br><span class="line"></span><br><span class="line">minikube dashboard			// minikube 提供可视化仪表盘</span><br><span class="line">minikube stop 				// 停止你的集群</span><br><span class="line">minikube delete --all 		// 删除所有集群和配置</span><br></pre></td></tr></table></figure>
  </article>
  
</article>


    </div>
  </div>
  <footer>
  
  
  <p>
    Powered by <a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a> | Theme <a target="_blank" rel="noopener" href="https://github.com/syy11cn/hexo-theme-linear">Linear</a> from <a target="_blank" rel="noopener" href="https://syy11.cn">Yiyang Sun</a>
  </p>
</footer>
  
  <script src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
  </script>
  <script>
    Waline({
      el: '#waline',
      placeholder: '',
      avatar: 'retro',
      visitor: true,
      requiredFields: ['nick', 'mail'],
      serverURL: '',
      emoji: [
        'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/bilibili',
        'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/qq',
        'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/alus',
        'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/tw-emoji',
        'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo',
        'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/tieba',
      ]
    });
  </script>
</body>

</html>